home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: Coding Standards
- Date: Tue, 12 Mar 1996 16:13:58 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4i47qr$q5e@news.halcyon.com>
- References: <4hj8ek$elu@sam.inforamp.net> <4hjh5c$elk@flood.weeg.uiowa.edu> <4hv2tm$e93@news.halcyon.com> <4i1ne4$g99@clarknet.clark.net>
- NNTP-Posting-Host: blv-pm3-ip12.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- gusty@clark.net (Harlan Messinger) wrote:
-
- >Norm Bryar (normanb@halcyon.com) wrote:
- >: Except you can't put consts in a header for everyone to use and you
- >: can't bitwise-OR enum values. #defines still have a place. <===
-
- >??? What about a header with the line,
-
- > extern const MyType MYCONST;
-
- >and a single module with the global definition
-
- > const MyType MYCONST(/* Initialization parameters here */);
-
- This is possible, although different still different than using
- #define. You can't compile
-
- switch( var )
- {
- case MYCONST:
- ...
-
- nor
-
- #if MSCVER >= MYCONST
-
-
- Probably most damning, however, is you can't easily bring MYCONST
- across module boundaries involving DLLs. With a #define in my header,
- both the EXE and the DLL know the value at compile time; with const, I
- have to export the data from the DLL (yucky) and tell the EXE to
- import the data (yucker!), which restricts me to early-binding to the
- DLL, as well as forcing lots of error-prone, hard-to-read overhead.
- All this just to avoid #define
-
- On the type-safety issue, you can always make your defines more
- typesafe
-
- #define A_LONG (123L)
- #define A_DWORD ((DWORD) 123u)
-
- etc.
-
- Trust me, there *is* a place for #define still!
-
- --Norm
-
-
-